项目地址:Sublime-JSHint

安装

  • Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X

  • 输入 install, 选择 Package Control: Install Package

  • 输入 js gutter, 选择 JSHint Gutter

配置

  • Ctrl+Shift+P or Cmd+Shift+P

  • 输入 jshint, 选择 Set node Path

  • 然后找到你的系统,并把node.exe地址填入即可

像这样:

{
  // Simply using `node` without specifying a path sometimes doesn't work :(
  // https://github.com/victorporof/Sublime-JSHint#oh-noez-command-not-found
  // http://nodejs.org/#download
  "node_path": {
    "windows": "C:/nodejs/node.exe", 
    "linux": "/usr/bin/nodejs",
    "osx": "/usr/local/bin/node"
  },

  // Automatically lint on edit (Sublime Text 3 only).
  // 如设置true会在编辑时运行jshint
  "lint_on_edit": false,

  // Configurable duration before re-linting.
  // 设置编辑后间隔多久才运行jshint
  "lint_on_edit_timeout": 1,

  // Automatically lint when a file is loaded.
  // 如设置true会在加载后运行jshint
  "lint_on_load": false,

  // Automatically lint when a file is saved.
  // 如设置true会在保存后运行jshint
  "lint_on_save": true,

  // Highlight problematic regions when selected.
  "highlight_selected_regions": true,

  // Log the settings passed to JSHint from `.jshintrc`.
  // 是否打印.jshintrc配置到控制台
  "print_diagnostics": false
}

使用

可多种方式,当然如果在JSHint设置了lint_on_savetrue将会在保存后自动运行。

  • 右键 -> JSHint -> Lint Code

  • Ctrl+Shift+P ,输入jshint 回车


帕奇式
924 声望71 粉丝

设计和管理是毕生的课题👨‍💻